﻿//------------------------------------------------------------
// AGame
// Copyright © 2020 - 2030. All rights reserved.
//------------------------------------------------------------
// 此文件由工具自动生成，请勿直接修改。
// 生成时间：2022-04-06 11:39:32.283
//------------------------------------------------------------

using GameFramework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;
using UnityGameFramework.Runtime;

/// <summary>
/// 。
/// </summary>
public class DTItem : DataRowBase
{
    private int m_Id = 0;

    /// <summary>
    /// 获取道具id，不可重复。
    /// </summary>
    public override int Id
    {
        get
        {
            return m_Id;
        }
    }

            /// <summary>
        /// 获取D=Dressing服饰；P=Pet宠物；S=Sticker贴纸。
        /// </summary>
        public string ItemType
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取0=不可被消耗；1=可以被消耗。
        /// </summary>
        public int Consumable
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取。
        /// </summary>
        public float Scale
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取。
        /// </summary>
        public float PosX
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取。
        /// </summary>
        public float PosY
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取。
        /// </summary>
        public string Res
        {
            get;
            private set;
        }
    
            public override bool ParseDataRow(string dataRowString, object userData)
        {
            string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
            for (int i = 0; i < columnStrings.Length; i++)
            {
                columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
            }

            int index = 0;
            index++;
            m_Id = int.Parse(columnStrings[index++]);
            index++;
            ItemType = columnStrings[index++];
            Consumable = int.Parse(columnStrings[index++]);
            Scale = float.Parse(columnStrings[index++]);
            PosX = float.Parse(columnStrings[index++]);
            PosY = float.Parse(columnStrings[index++]);
            Res = columnStrings[index++];

            GeneratePropertyArray();
            return true;
        }

        public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
        {
            using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
            {
                using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
                {
                    m_Id = binaryReader.Read7BitEncodedInt32();
                    ItemType = binaryReader.ReadString();
                    Consumable = binaryReader.Read7BitEncodedInt32();
                    Scale = binaryReader.ReadSingle();
                    PosX = binaryReader.ReadSingle();
                    PosY = binaryReader.ReadSingle();
                    Res = binaryReader.ReadString();
                }
            }

            GeneratePropertyArray();
            return true;
        }
    
            private void GeneratePropertyArray()
        {

        }
}
